/*  KKS - KinoKassenSystem 2013
 * 
 *  author Sebastian Schöppner
 * 
 *  Custom Fonts
 * 
 *  
 */
package kks;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DBuse
{
    Connection con;
    
    /**
    * create use object for the database
    * <p>
    *
    * a connection is establish on creating a new object
    * 
    * 
    */
    public DBuse()
    {
        try
        {
            // get the connection to the database else throw error
            con = DBConnection.getConnection();
            if (con == null)
                throw new Exception("Connection-Error");     		
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }    	
    }

    /**
    * create use object for the database
    * <p>
    *
    * @param the sql statement
    * 
    * @return the resultset of the sql statement
    * @exception returns null
    * 
    */
    public ResultSet getMovies(String statement) 
    { 
        try 
        {
            // creat statement object
            Statement stmt = con.createStatement(); 

            String select_statement= statement;
            ResultSet rset = stmt.executeQuery (select_statement);
            return rset; 		
        }  
        catch (SQLException e)
        {
            return null;

        }  
    }
}
